bindgen 0.18.0

A binding generator for Rust
Documentation

rust-bindgen

A native binding generator for the Rust language.

rust-bindgen was originally ported from clay's bindgen.

Documentation

Requirements

  • Clang >= 3.5

Installing

$ cargo install bindgen

Bindgen will be dynamically linked to your default clang version. See clang-sys if you want to use an other version or do a static link build. The clang-sys feature static can be activated via the bindgen feature clang_sys/static.

Usage

Command Line

$ bindgen <header> [<bindgen options>] [-- <clang options>]

See --help for a list of the supported options.

Plugin

    bindgen!(header, options...)

The use of this plugin requires the use of a nightly compiler.

Options:

Option Name Type Default
link str
match str
builtins bool true
allow_unknown_types bool false
clang_args str

Examples

Generate a Lua binding with the CLI

bindgen --link lua --builtins /usr/include/lua.h -o lua.rs

Generate a Lua binding with the plugin

Cargo.toml

[dependencies]
bindgen = "*"

main.rs

#![feature(plugin)]
#![plugin(bindgen)]

mod lua_bindings {
    bindgen!("/usr/include/lua.h", link="lua", builtins=true)
}